package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.Tbdepartment;

public interface IHWCTbdepartmentDAO extends CrudRepository<Tbdepartment,Long> {
	/**
	 * 查询所有部门
	 * @return
	 */
	@Query("select new	Tbdepartment(d.departmentNo,d.address,d.departmentName) from  Tbdepartment d")
	public List<Tbdepartment>queryAllTbdepartment();
	 /**
	  * 分页显示所有部门
	  */
	@Query("select d from Tbdepartment d where d.departmentNo !='9999' order by d.departmentNo desc")
	public List<Tbdepartment> findTbdepartmentPage(Pageable Pageble);
	/**
	 * 根据科室名称模糊查询
	 */
	@Query("select d from Tbdepartment d where d.departmentName like %?1%")
	public List<Tbdepartment>findBydepartmentName(String departmentName);	
	/**
	 * 根据科室名称模糊查询分页
	 */
	@Query("select d from Tbdepartment d  where d.departmentName like %?1% order by d.departmentNo desc")
	public List<Tbdepartment> findByTbdepartmentPageDepartmentName(Pageable pageble,String departmentName);
	/**
	 * 根据科室地址模糊查询
	 */
	@Query("select d from Tbdepartment d where d.address like %?1%")
	public List<Tbdepartment>findByAddress(String address);
	
	/**
	 * 根据科室地址模糊查询分页显示	 
	 * */
	@Query("select d from Tbdepartment d where d.address like %?1% order by d.departmentNo desc")
	public List<Tbdepartment> findByAddressPage(Pageable pageble,String address);
}
